package com.dc.refactoring._4_简化条件表达式._1_DecomposeConditional;

import java.util.Date;

public class Demo1 {

    /**
     * 冬季率
     */
    int winterRate = 10;
    /**
     * 夏季率
     */
    int summerRate = 15;
    /**
     * 冬季服务费
     */
    int winterServiceCharge = 20;

    public static final Date SUMMER_START = new Date();
    public static final Date SUMMER_END = new Date();

    /**
     * 通过给定日期，获取最终的价格
     * @param date              日期
     * @param quantity          单价
     * @return                  最终价格
     */
    public double fun1(Date date, int quantity){
        if (date.before(SUMMER_START) || date.after(SUMMER_END)){
            return quantity * winterRate + winterServiceCharge;
        }else {
            return quantity * summerRate;
        }
    }

}
